home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Procedure for initializing the TNCs *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen. All rights *)
- (* reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$DEFINE DEBUG_TINIT}
- {$DEFINE DEBUG_BPQHOST1}
- {$UNDEF DEBUG_TINIT}
- {$UNDEF DEBUG_BPQHOST1}
-
- (*===========================================================================*)
- (* Shared subroutines *)
- (*===========================================================================*)
-
- PROCEDURE gc;
-
- VAR
- t_str : STRING;
-
- BEGIN;
-
- REPEAT
- t_str := garbage_collect_tnc;
- IF t_str <> '' THEN
- window_write(active_port^.port_char + 'G:', t_str);
- UNTIL t_str = '';
-
- IF active_port^.port_type <> port_modem THEN
- EXIT;
-
- IF active_tcb^.tnc_tth^.data67_count > 0 THEN
- BEGIN;
- MOVE(active_tcb^.tnc_tth^.data67[1], t_str[1],
- active_tcb^.tnc_tth^.data67_count);
- window_write(active_port^.port_char + 'G:', t_str);
- END;
-
- IF active_tcb^.tnc_data.str_data <> '' THEN
- window_write(active_port^.port_char + 'G:',
- active_tcb^.tnc_data.str_data);
-
- END;
-
- PROCEDURE cmd_it(s : STRING);
- BEGIN;
- cmd_tnc(@s, TRUE);
- END;
-
- PROCEDURE modem_cmd(s : STRING);
- BEGIN;
- send_tnc_data_str('AT' + s + cr);
- send_flush;
- DELAY(100);
- gc;
- END;
-
- (*===========================================================================*)
- (* Initialize the TNCS *)
- (*===========================================================================*)
-
- PROCEDURE tinit;
-
- CONST debug = FALSE;
-
- VAR
- f : TEXT;
- i : WORD;
- r : REGISTERS;
- save_color : BYTE;
- t_str : STRING;
-
- {$I BBTINITF.PAS} (* Initialize TNC with file *)
- {$I BBTINITT.PAS} (* Actually initialize TNC *)
-
- BEGIN;
-
- save_color := active_tcb^.w_color;
-
- (*-------------------------------------------------------------------------*)
- (* Start with first port *)
- (*-------------------------------------------------------------------------*)
-
- active_port := ring_port;
-
- (*-------------------------------------------------------------------------*)
- (* Loop thru all ports *)
- (*-------------------------------------------------------------------------*)
-
- REPEAT
-
- {$IFDEF DEBUG_TINIT}
- WRITELN('INIT of COM ', active_port^.com_number);
- {$ENDIF}
-
- active_tcb^.tcb_port := active_port;
-
- IF (active_port^.port_type <> port_pcpa)
- AND (active_port^.port_type <> port_bpqhost) THEN
- BEGIN;
- r.AH := 4;
- r.DX := active_port^.com_number - 1;
- INTR(tnc_interrupt, r);
- IF r.AX <> $AA55 THEN
- BEGIN;
- WRITELN;
- WRITELN('***** ERROR *****');
- WRITELN('MBBIOS not active for COM', active_port^.com_number);
- RUNERROR(mbbios_not_found);
- END;
- END;
-
- init_this_tnc;
-
- active_port := active_port^.next_port;
-
- UNTIL active_port = ring_port;
-
- (*-------------------------------------------------------------------------*)
- (* Tell user we are done *)
- (*-------------------------------------------------------------------------*)
-
- window_write('', 'TNCs are initialized');
-
- active_tcb^.w_color := save_color;
-
- END;
-
- (*===========================================================================*)
- (* Close the TNCs *)
- (*===========================================================================*)
-
- PROCEDURE tclose;
- VAR
- i : BYTE;
- r : REGISTERS;
- save_color : BYTE;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Save color *)
- (*-----------------------------------------------------------------------*)
-
- save_color := active_tcb^.w_color;
-
- (*-----------------------------------------------------------------------*)
- (* Loop thru all the TNCS *)
- (*-----------------------------------------------------------------------*)
-
- active_port := ring_port;
-
- REPEAT
-
- WITH active_tcb^, active_port^ DO
- BEGIN;
-
- tcb_port := active_port;
- w_color := port_color;
-
- FOR i := 1 TO max_chan DO
- connected^[i] := NIL;
-
- channel := 0;
- port_chan_s := port_char + '0';
-
- IF NOT port_sub_port THEN
- BEGIN;
-
- FILLCHAR(tnc_data, SIZEOF(tnc_data), 0);
- FILLCHAR(tnc_htt^, tnc_b_size, 0);
-
- CASE port_type OF
-
- port_aeapk232, port_g8bpq :
- BEGIN;
- cmd_it('MN0');
- cmd_it('MC0');
-
- cmd_it('MN');
-
- cmd_it('UR0');
- cmd_it('CFNONE');
- END;
-
- port_bpqhost, port_modem :
- ;
-
- ELSE
- BEGIN;
- cmd_it('MN');
-
- cmd_it('M');
-
- cmd_it('Y0');
- END;
-
- END; (*----- End port type case statement ---------------------*)
-
- FOR i := 0 TO max_chan DO
- BEGIN;
-
- channel := i;
-
- port_chan_s := port_char + byte_to_char[i];
-
- IF i <> 0 THEN
- cmd_tnc(@disc_cmd, TRUE);
-
- IF port_type = port_bpqhost THEN
- BEGIN;
- r.AH := bpq_open;
- r.AL := i + 1;
- r.CL := 0;
- r.DL := 0;
- INTR(com_number, r);
- END;
-
- IF port_type = port_modem THEN
- DELAY(200);
-
- REPEAT
-
- send_recv_tnc(2);
- IF NOT tnc_null THEN
- window_write('', tnc_data.str_data);
-
- UNTIL tnc_null;
-
- END; (*----- End channel loop -------------------------------*)
-
- END; (*----- End sub port check ---------------------------------*)
-
- END; (*----- End addressing -----------------------------------------*)
-
- active_port := active_port^.next_port;
-
- UNTIL active_port = ring_port;
-
- END;